package com.itheima.a07;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.util.StringValueResolver;

import javax.annotation.PostConstruct;

/**
 * @author: AirMan
 * @date: 2025/4/11 15:50
 * @description:
 */
public class MyBean1 implements InitializingBean, ApplicationContextAware, BeanNameAware, EmbeddedValueResolverAware {
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("InitializingBean 初始化");
    }

    @PostConstruct
    public void post(){
        System.out.println("PostConstruct 初始化");
    }

    public void beanInit(){
        System.out.println("beanInitMethod 初始化");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("ApplicationContext 初始化");
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("BeanNameAware 初始化");
    }

    @Override
    public void setEmbeddedValueResolver(StringValueResolver resolver) {
        System.out.println("EmbeddedValueResolverAware 初始化");
    }

    @Autowired
    public Bean3 autowirede(){
        System.out.println("Autowired 依赖注入");
        return new Bean3();
    }
}
